package controllers

import (
	"github.com/revel/revel"
	"github.com/leanote/leanote/app/info"
)

type City struct {
	BaseController
}

func (c City)Provinces() revel.Result  {
	ps:=citiesService.Provinces()
	re:=info.NewApiRe()
	return c.RenderJson(re.Success(ps))
}

func (c City)Cities() revel.Result  {
	cities:=citiesService.Cities()
	re:=info.NewApiRe()
	return c.RenderJson(re.Success(cities))
}

func (c City)Districts() revel.Result  {
	districts:=citiesService.Districts()
	re:=info.NewApiRe()
	return c.RenderJson(re.Success(districts))
}

func (c City)Hots() revel.Result  {
	hots:=citiesService.Hots()
	re:=info.NewApiRe()
	return c.RenderJson(re.Success(hots))
}

func (c City)All()revel.Result  {
	ps:=citiesService.Provinces()
	cities:=citiesService.Cities()
	districts:=citiesService.Districts()

	type data struct {
		Provinces []info.Province `json:"provinces"`
		Cities []info.City `json:"cities"`
		Districts []info.District `json:"districts"`
	}

	re:=info.NewApiRe()
	re.Success(data{ps,cities,districts})
	return c.RenderJson(re)
}

/**针对不付项款而定制的接口 */
func (c City)Guoliao()revel.Result  {

	type guoliao struct {
		Status int `json:"status"`
		Message string `json:"message"`
		Data interface{} `json:"data"`
	}

	type crash struct {
		Crash bool `json:"crash"`
	}

	data:=crash{Crash:false}
	re:=guoliao{Status:200000,Message:"项款尚未结清，请结清后自动恢复！",Data:data}
	return c.RenderJson(re)
}